package com.bai;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;

public class Easy {
    public static void main(String[] args) throws Exception {
        // 1. 设置参数（全局只需设置一次）
        Factory.setOptions(getOptions());

        String res = Factory.Util.AES().decrypt("KdIVmQMrBZ3kF85nqtawww12UrepqYeXb7enyVNETMN928ibNy81O9sZ/9PGXcsvGr6QhDiBCH0DZ/OL2fmAg7vWhe9/Gn1dBERUQeckQ3pA+eAGo8a+3P6Jqucvf2nb2GdPPyvd2fheTTUhDE7JyDgu72uITWbKUv0G+5YMFWU=");
        System.out.println(res);
        //        try {
//            // 2. 发起API调用（以创建当面付收款二维码为例）
//            AlipayTradePrecreateResponse response = Payment.FaceToFace()
//                    .preCreate("Apple iPhone11 128G", "2234567890", "5799.00");
//            // 3. 处理响应或异常
//            if (ResponseChecker.success(response)) {
//                System.out.println("调用成功");
//            } else {
//                System.err.println("调用失败，原因：" + response.msg + "，" + response.subMsg);
//            }
//        } catch (Exception e) {
//            System.err.println("调用遭遇异常，原因：" + e.getMessage());
//            throw new RuntimeException(e.getMessage(), e);
//        }

    }
    private static Config getOptions() {
        Config config = new Config();
        config.protocol = "https";
        config.gatewayHost = "https://openapi.alipay.com/gateway.do";
        config.signType = "RSA2";
        config.appId = "2021005156674866";
        // 为避免私钥随源码泄露，推荐从文件中读取私钥字符串而不是写入源码中
        config.merchantPrivateKey = "MIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQC9GkeK2YQg5TWVsnaCP68yds8RszmTJy/IcWjIXueUIBiGma4C/Exl4qKJ96/BoasDLEGDfmqvZOGfXFZM6IeItd6507xabmBltvjxcZzdeNa8ZlJJEPVgCL6+v22RzXxDIDPzJs682RXwECryvB1GOJ2Y5oeAICQ61Ze6gQg1nC8fFLo6cY073YYHbrrdfLi2QJRa9faN7jWsG8sRmknJkqILzjYFO2xX402GgrAOWGnGfmJboD+WVNExytOKxcdjuiFNWYswMWjnI25C1uJ7coyI06m7lE+oC/Nli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e9NL9stDde3F7tB6VQKBgAm8VcQ5laz+XGfJQoFWIMK+BDBXvhTfjBtQv09Hpc1AAxG4/j0DhTwBu2XaT8g7isqZGrjzKS2HvoELE7WTXiH+78XHfBZ3WJ+7/JYsEhKD5hWhdzK5qYd7cWyHsh1HShkRRpJkFIe5ts7sZs72e5Oz7Fu7OzDWpxlTBosI6r/3";

//        //注：证书文件路径支持设置为文件系统中的路径或CLASS_PATH中的路径，优先从文件系统中加载，加载失败后会继续尝试从CLASS_PATH中加载
//        config.merchantCertPath = "<-- 请填写您的应用公钥证书文件路径，例如：/foo/appCertPublicKey_2019051064521003.crt -->";
//        config.alipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径，例如：/foo/alipayCertPublicKey_RSA2.crt -->";
//        config.alipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径，例如：/foo/alipayRootCert.crt -->";
        //注：如果采用非证书模式，则无需赋值上面的三个证书路径，改为赋值如下的支付宝公钥字符串即可
         config.alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiSAM5juc9xpSmlo5Gg3BG1j1pPFCi60riR4Msb93umDBOlJdo2GibLQ2wc1jyg8FRWFI4ndadEESzFhimaYORSZbnb37gX7bvvirGW8KdNV28p5LD3ro/Q4e0ZEr1s67RjdD6vbV7OQ6UBYr2t89KxVEC6Rv/TpYi47WcsTOBZkxltPDq0G83UDTfKNZ0YlXJLVulxpjBUOWzfxow4JRpLqCWeQ4NzofYuJMwvK7zIeFeQEq4QNQXtnzQU3Vhz6/FIfHv9DnD5nArbZrIrzJDmgKBSrvoZHzCw7YteXoUGQgwnvD5PIonLWl3zg3fKzFs93AWQFY6fkSTvL1evu77wIDAQAB";
        //可设置异步通知接收服务地址（可选）
//        config.notifyUrl = "https://www.test.com/callback";
        //可设置AES密钥，调用AES加解密相关接口时需要（可选）
        config.encryptKey = "wFi64IqN5wJQePugUyHNWQ==";
        return config;
    }
}
